# ~*~ coding: utf-8 ~*~
import time

from apps.common.dbbase import BaseModel
from apps.common.utils import generate_uuid
from apps.extensions import db

__all__ = ['Function']


class Function(BaseModel):
    __tablename__ = 'tasks_periodic_function'

    id = db.Column(db.String(36), default=generate_uuid, primary_key=True)

    name = db.Column(db.String(200), unique=True)
    method = db.Column(db.String(128), nullable=False)
    description = db.Column(db.TEXT, nullable=True)

    create_by = db.Column(db.VARCHAR(32), nullable=True)
    create_time = db.Column(db.INT, default=time.time)
    update_time = db.Column(db.INT, default=time.time, onupdate=time.time)

    def __str__(self):
        return '<Function: {}>'.format(self.name)
